package com.example.app;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

import java.io.IOException;

public class VirtualMachineDemo {

    public static void main(String[] args) throws IOException, AttachNotSupportedException, AgentLoadException, AgentInitializationException {
        String jvmPid = "14304";
        VirtualMachine jvm = VirtualMachine.attach(jvmPid);
        jvm.loadAgent("D:\\Code\\projects\\java-agent\\simple-agent\\src\\SimpleAgent.jar");//agentFilePath为agent的路径
        jvm.detach();
    }
}
